
var Tool = require("../../../utils/ztool.js");
var tool = new Tool();
var util = require('../../../utils/util.js')
var traveldetail;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    sendTag: 0,
    // 修改订单传过来的idd
    IDD: '',


    title: '',
    geton: '',
    getoff: '',
    seatNum: '',
    personNum: '',
    carNum: '',
    days: '1',
    price: '',
    dateStartAll: '',
    dateStart: '',
    dateStartTime: '',
    dateEndAll: '',
    dateEnd: '',
    dateEndTime: '',
    arrayPrice: [
      { name: "是", value: '1', checked: true },
      { name: '否', value: '0', checked: false }
    ],
    BoolPrice: 1,
    arrayStatus: [
      { name: "已确认", value: "1", checked: false },
      { name: "未确认", value: "0", checked: true },
      { name: "取消", value: "2", checked: false }
    ],
    OrderStatus: '0',
    route: '',
    Addition: '',
    selectTag: 0,
    selectTagAdd: 0,
    selectTagDelete: 0,
    list: [],
    listAdd: [],
    listSearch: [],
    listDelete: [],
    listDeleteSearch: [],
    AddKeyWord: '',
    // carCompanyName: '',

    carCompanyIDAdd: '',
    carCompanyIDDelete: '',
    removeArr: [],
    listchange: [],
    arrcompare2: [],//初始的数组
    arrlatest: [],//修改完的数组
    dateAndroute1: [],//行程和日期数组
    // carCompanypersontel: '',
    selectCompanyAdd: 0,

    carCompanyNamemain: '',//主页面车公司
    carCompanyIDmain: '',//主页面车公司ID
    carCompanypersonmain: '',//主页面车公司联系人
    carCompanypersontel: '', //主页面车公司联系人电话

    carCompanyName: '',//选择的车公司
    carCompanyID: '',//选择的车公司ID
    carCompanyperson: '',//选择的车公司联系人
    carCompanytel: '',//选择的车公司联系人电话

    carCompanyName2: '',//手动输入的车公司
    carCompanyperson2: '',//手动输入的车公司联系人
    carCompanytel2: '',//手动输入的车公司联系人电话

    timeCheck1: false, //开始时间是否选上
    timeCheck2: false,  //结束时间是否选上
  },

  switchChange1: function (e) {
    var that = this
    if (e.detail.value == true) {
      that.setData({
        timeCheck1: true
      })
    } else {
      that.setData({
        timeCheck1: false
      })
    }
    console.log(that.data.timeCheck1)
  },

  switchChange2: function (e) {
    var that = this
    if (e.detail.value == true) {
      that.setData({
        timeCheck2: true
      })
    } else {
      that.setData({
        timeCheck2: false
      })
    }
    console.log(that.data.timeCheck2)
  },

  //隐藏添加车公司
  hideModalCompanyAdd: function () {
    this.setData({
      selectCompanyAdd: 0,
    });


  },
  //添加车公司弹框
  getusecarcompanymain: function () {
    if (!this.data.IDD) {
      this.setData({
        carCompanyName: '',
        carCompanyperson: '',
        carCompanytel: '',
        carCompanyID: '',
        carCompanyName2: '',
        carCompanyperson2: '',
        carCompanytel2: '',
        selectCompanyAdd: 1,
      })
    } else {
      if (this.data.listchange.CarCompanyID == 0) {
        this.setData({
          carCompanyName: '',
          carCompanyperson: '',
          carCompanytel: '',
          carCompanyID: '',
          carCompanyName2: '',
          carCompanyperson2: '',
          carCompanytel2: '',
          selectCompanyAdd: 1,
        })

      } else {
        this.showError('订单已发送不能修改此栏')
        return
      }
    }

  },

  //确定车公司
  confirmusercompany: function () {
    if (this.data.carCompanyName.length > 0) {
      if (this.data.carCompanyperson2.length > 0 || this.data.carCompanytel2.length > 0 || this.data.carCompanyName2.length > 0) {
        this.showError('请勿都输入内容')
        return
      }

      this.setData({
        carCompanypersonmain: this.data.carCompanyperson,
        carCompanypersontel: this.data.carCompanytel,
        carCompanyNamemain: this.data.carCompanyName,
        carCompanyIDmain: this.data.carCompanyID,
        selectCompanyAdd: 0,
      })
    } else {
      this.setData({
        carCompanypersonmain: this.data.carCompanyperson2,
        carCompanypersontel: this.data.carCompanytel2,
        carCompanyNamemain: this.data.carCompanyName2,
        carCompanyIDmain: '',
        selectCompanyAdd: 0,
      })
    }
    console.log(this.data.carCompanyIDmain)
  },


  //车公司
  CarCompany: function () {
    // if (!this.data.IDD) {
    getServiceData(this);
    this.setData({
      selectTag: 1,
      selectCompanyAdd: 0,
    })
    // } else {
    //   if (this.data.listchange.CarCompanyID == 0) {
    //     getServiceData(this);
    //     this.setData({
    //       selectTag: 1
    //     })

    //   } else {
    //     this.showError('订单已发送不能修改此栏')
    //     return
    //   }
    // }

  },

  pulltoOrder: function (e) {
    // this.data.carCompanypersontel = ''
    this.setData({
      carCompanyName: e.currentTarget.dataset.comname,
      carCompanyID: e.currentTarget.dataset.comid,
      // carCompanypersontel: e.currentTarget.dataset.comtel,
      carCompanytel: e.currentTarget.dataset.comtel,
      carCompanyperson: e.currentTarget.dataset.comperson,
      selectTag: 0,
      selectCompanyAdd: 1,
    });
    console.log(this.data.carCompanyID)
    // console.log(this.data.carCompanypersontel);
    this.confirmusercompany()
  },

  inputusercarname: function (e) {
    var that = this
    var str = e.detail.value
    that.setData({
      carCompanyName2: str
    })
    console.log(that.data.carCompanyName2)
  },
  inputusercartel: function (e) {
    var that = this
    var str = e.detail.value
    that.setData({
      carCompanytel2: str
    })
    console.log(that.data.carCompanytel2)
  },

  inputusercarperson: function (e) {
    var that = this
    var str = e.detail.value
    that.setData({
      carCompanyperson2: str
    })
    console.log(that.data.carCompanyperson2)
  },

  //添加合作公司弹框显示
  addCarCompany: function (e) {
    this.setData({
      selectTag: 0,
      selectTagAdd: 1
    })
  },

  //删除合作车公司弹框显示
  deleteCarCompany: function () {
    this.setData({
      listDelete: this.data.list,
      listDeleteSearch: this.data.list,
      selectTag: 0,
      selectTagDelete: 1
    })
  },


  //搜索内容
  inputsearchAdd: function (e) {
    var str = e.detail.value
    this.setData({
      AddKeyWord: str
    })
  },

  //添加合作公司搜索
  addSearch: function () {
    getDataAddCar(this)
  },

  //添加合作公司弹框隐藏
  hideModalAdd: function () {
    this.setData({
      selectTagAdd: 0,
      listAdd: [],
      AddKeyWord: ''
    });
  },
  //删除合作公司弹框隐藏
  hideModalDelete: function () {
    this.setData({
      selectTagDelete: 0,
      listDelete: [],
      listDeleteSearch: []
    });

  },

  //移除合作团队
  removeFromTeam: function (e) {
    var that = this
    wx: wx.showModal({
      title: '确定移除?',
      content: '您确定要移除这个合作团队吗？',
      showCancel: true,
      cancelText: '取消',
      confirmText: '确定',
      success: function (res) {
        if (res.confirm) {
          var arr = e.currentTarget.dataset
          that.setData({
            removeArr: arr.arr,
            carCompanyIDDelete: arr.arr.CompanyID
          });
          remove(that)
        } else {

        }
      },
      fail: function (res) { },
      complete: function (res) { },
    })
  },


  //拉进合作团队
  pulltoTeamAdd(e) {
    var that = this
    wx: wx.showModal({
      title: '确定添加？',
      content: '您确定要将这个车公司添加进合作团队吗？',
      showCancel: true,
      cancelText: '取消',
      confirmText: '确定',
      success: function (res) {
        if (res.confirm) {
          that.setData({
            carCompanyIDAdd: e.currentTarget.dataset.comid,
          });
          that.hideModalAdd()
          pulltoTeam(that)

        } else {

        }
      },
      fail: function (res) { },
      complete: function (res) { },
    })
  },

  hideModal: function () {
    this.setData({
      selectTag: 0
    });
  },

  callPhone: function (e) {
    if (e.currentTarget.id == "") {
      wx.showToast({
        title: '号码为空',
        icon: 'none',
      });
      return;
    }
    wx.makePhoneCall({
      phoneNumber: e.currentTarget.id //仅为示例，并非真实的电话号码
    });
  },

  //标题
  inputTitle: function (e) {
    var str = e.detail.value
    this.setData({
      title: str
    })
  },
  //上车地点
  inputGeton: function (e) {
    var str = e.detail.value
    this.setData({
      geton: str
    })
  },
  //下车地点
  inputGetoff: function (e) {
    var str = e.detail.value
    this.setData({
      getoff: str
    })
  },
  //座位数
  inputseats: function (e) {
    var str = e.detail.value
    this.setData({
      seatNum: str
    })
  },
  //人数
  inputpersonNum: function (e) {
    var str = e.detail.value
    this.setData({
      personNum: str
    })
  },
  //车辆数
  inputcarNum: function (e) {
    var str = e.detail.value
    this.setData({
      carNum: str
    })
  },

  //预计天数
  inputdays: function (e) {
    var str = e.detail.value
    this.setData({
      days: str
    })
  },
  //预算价格
  inputPrice: function (e) {
    var str = e.detail.value
    this.setData({
      price: str
    })
  },
  //开始日期
  bindDateChangeStart: function (e) {
    this.setData({
      dateStart: e.detail.value
    });
    // var day = DateDiff(this.data.dateEnd, this.data.dateStart) + 1
    var stringTime = this.data.dateEnd + ' 00:00:00';
    var stringTime2 = this.data.dateStart + ' 00:00:00';
    stringTime = stringTime.replace(/-/g, '/');
    stringTime2 = stringTime2.replace(/-/g, '/');
    var timestamp = Date.parse(new Date(stringTime));
    var timestamp2 = Date.parse(new Date(stringTime2));
    console.log(timestamp)
    console.log(timestamp2)
    timestamp = timestamp / 1000;
    timestamp2 = timestamp2 / 1000;
    var day = (timestamp - timestamp2) / 86400 + 1;
    console.log(day)
    if (day <= 0) {
      day = 1
    }
    this.setData({
      days: day
    })
  },

  bindDateChangeStartTime: function (e) {
    this.setData({
      dateStartTime: e.detail.value
    });
  },


  //结束日期
  bindDateChangeEnd: function (e) {
    this.setData({
      dateEnd: e.detail.value
    });
    // var day = DateDiff(this.data.dateEnd, this.data.dateStart) + 1


    var stringTime = this.data.dateEnd + ' 00:00:00';
    var stringTime2 = this.data.dateStart + ' 00:00:00';
    stringTime = stringTime.replace(/-/g, '/');
    stringTime2 = stringTime2.replace(/-/g, '/');
    var timestamp = Date.parse(new Date(stringTime));
    var timestamp2 = Date.parse(new Date(stringTime2));
    console.log(timestamp)
    console.log(timestamp2)
    timestamp = timestamp / 1000;
    timestamp2 = timestamp2 / 1000;
    var day = (timestamp - timestamp2) / 86400 + 1;
    console.log(day)
    if (day <= 0) {
      day = 1
    }
    this.setData({
      days: day
    })

  },
  bindDateChangeEndTime: function (e) {
    this.setData({
      dateEndTime: e.detail.value
    });
  },

  //是否含费
  checkboxPrice: function (e) {
    console.log('radio发生change事件，携带value值为：', e.detail.value)
    this.setData({
      BoolPrice: e.detail.value
    });
  },
  //订单状态
  radioBoxStatus: function (e) {
    console.log('radio发生change事件，携带value值为：', e.detail.value)
    this.setData({
      OrderStatus: e.detail.value
    });
  },
  //行程详情
  inputRoute: function (e) {
    this.setData({
      route: e.detail.value
    });
  },
  //备注
  inputAddition: function (e) {
    this.setData({
      Addition: e.detail.value
    });
  },

  //listSearch
  inputsearch: function (e) {
    var that = this
    var arr = []
    var keyWord = e.detail.value

    for (var i = 0; i < that.data.listSearch.length; i++) {

      if (that.data.listSearch[i].CompanyName.indexOf(keyWord) >= 0 || that.data.listSearch[i].Telphone.indexOf(keyWord) >= 0) {
        arr.push(that.data.listSearch[i]);
      }
    }
    if (keyWord != null && keyWord != undefined && keyWord != '' && keyWord != ' ' && keyWord.length != 0) {
      if (arr.length == 0) {
        wx.showToast({
          title: '没有对应的车公司',
          icon: 'none',
          duration: 1000,
        })
      }
      that.setData({
        list: arr,
      });
    } else {
      that.setData({
        list: that.data.listSearch
      });
    }


  },

  inputsearchDelete: function (e) {
    var that = this
    var arr = []
    var keyWord = e.detail.value

    for (var i = 0; i < that.data.listDeleteSearch.length; i++) {

      if (that.data.listDeleteSearch[i].CompanyName.indexOf(keyWord) >= 0 || that.data.listDeleteSearch[i].Telphone.indexOf(keyWord) >= 0) {
        arr.push(that.data.listDeleteSearch[i]);
      }
    }
    if (keyWord != null && keyWord != undefined && keyWord != '' && keyWord != ' ' && keyWord.length != 0) {
      that.setData({
        listDelete: arr,
      });
    } else {
      that.setData({
        listDelete: that.data.listDeleteSearch
      });
    }
  },


  //提交订单
  confirm: function () {
    if (this.data.sendTag == 0) {
      this.data.sendTag = 1
      goPush(this)
    }
  },
  //修改订单
  xiugai: function () {
    if (this.data.sendTag == 0) {
      this.data.sendTag = 1
      xiugai(this)
    }
  },

  //新增订单推送方法
  PushToCarCompany: function (idd) {
    var that = this
    if (that.data.carCompanypersontel.length == 0) {
      return
    }
    wx.showToast({
      title: '正在加载...',
      icon: 'loading',
      duration: 10000
    });

    wx.request({
      url: 'https://www.lanshuicar.com/Server/Weixin/WxPushHdl.ashx',
      data: {
        idd: idd,
        tel: that.data.carCompanypersontel,
        title: '您有新的订单来了',
        content: '旅行社给您发送了一个新的订单'
      },
      method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      // header: {}, // 设置请求的 header
      success: function (res) {
        if (res.statusCode == 404) {
          //接口加载失败
          console.log('加载接口错误');
          //隐藏Toast
          wx.hideToast();
          //显示错误信息
          that.showError('接口请求失败，请重试')
          return
        }
        // success
        // var data = tool.getRegularJson(res.data);
        var code = res.data.code;
        console.log(res);
        if (code == 0) {
          console.log('post推送请求成功')

        } else {
          console.log(res)
        }
      },
      fail: function (res) {
        console.log(res)
      },
      complete: function () {
        // complete
        wx.hideToast();
        wx.stopPullDownRefresh();
      }
    })
  },

  //修改订单推送方法
  PushToCarCompanyChange: function (idd) {
    var that = this
    if (that.data.carCompanypersontel.length == 0) {
      return
    }
    wx.showToast({
      title: '正在加载...',
      icon: 'loading',
      duration: 10000
    });

    wx.request({
      url: 'https://www.lanshuicar.com/Server/Weixin/WxPushHdl.ashx',
      data: {
        idd: idd,
        tel: that.data.carCompanypersontel,
        title: '您有订单变更',
        content: '旅行社给您的订单发生了变更，请您及时关注'
      },
      method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      // header: {}, // 设置请求的 header
      success: function (res) {
        // success
        // var data = tool.getRegularJson(res.data);
        if (res.statusCode == 404) {
          //接口加载失败
          console.log('加载接口错误');
          //隐藏Toast
          wx.hideToast();
          //显示错误信息
          that.showError('接口请求失败，请重试')
          return
        }

        var code = res.data.code;
        console.log(res);
        if (code == 0) {
          console.log('post推送请求成功')

        } else {
          console.log(res)
        }
      },
      fail: function (res) {
        console.log(res)
      },
      complete: function () {
        // complete
        wx.hideToast();
        wx.stopPullDownRefresh();
      }
    })
  },


  //修改行程和时间订单推送方法
  PushToGuiderDriverChengke: function (tel) {
    var that = this
    if (that.data.carCompanypersontel.length == 0) {
      return
    }
    wx.showToast({
      title: '正在加载...',
      icon: 'loading',
      duration: 10000
    });

    wx.request({
      url: 'https://www.lanshuicar.com/Server/Weixin/WxPushHdl.ashx',
      data: {
        idd: that.data.IDD,
        tel: tel,
        title: '您有订单变更',
        content: '行程或日期发生变更，请您及时关注'
      },
      method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      // header: {}, // 设置请求的 header
      success: function (res) {
        if (res.statusCode == 404) {
          //接口加载失败
          console.log('加载接口错误');
          //隐藏Toast
          wx.hideToast();
          //显示错误信息
          that.showError('接口请求失败，请重试')
          return
        }
        // success
        // var data = tool.getRegularJson(res.data);
        var code = res.data.code;
        console.log(res);
        if (code == 0) {
          console.log('post推送请求成功')

        } else {
          console.log(res)
        }
      },
      fail: function (res) {
        console.log(res)
      },
      complete: function () {
        // complete
        wx.hideToast();
        wx.stopPullDownRefresh();
      }
    })
  },



  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    var IDD1 = options.IDD;
    this.setData({
      IDD: IDD1,
    });
    if (!IDD1) {
      console.log('new')
      var time1 = util.formatTime1(new Date());
      var time2 = util.formatTime2(new Date());
      this.setData({
        dateStart: time1,
        dateStartTime: '00:00',
        dateEnd: time1,
        dateEndTime: '23:00'
      });
    } else {
      console.log('change')
      getServiceDataChange(this)
    }
  },
  //提示toast
  showError: function (msg) {
    var that = this;
    that.setData({
      formError: true,
      errorMessage: msg
    });

    setTimeout(function () {
      that.setData({
        formError: false,
        errorMessage: '未知错误'
      });
    }, 2000);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },



  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  isInteger: function (obj) {
    return obj % 1 === 0
  }

})

function getServiceData(that) {
  //初始化list
  that.data.list = []
  that.data.listSearch = []
  // listSearch: []
  wx.showToast({
    title: '正在加载...',
    icon: 'loading',
    duration: 10000
  });
  var userInfo = wx.getStorageSync('userInfo');
  wx.request({
    url: 'https://www.lanshuicar.com/Server/CooPeratePartners.ashx',
    data: {
      PageSize: '200',
      PageIndex: '1',
      Type: '1',
      ID: userInfo.ID,
      CType: '1',
      Info: '0'
    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function (res) {
      if (res.statusCode == 404) {
        //接口加载失败
        console.log('加载接口错误');
        //隐藏Toast
        wx.hideToast();
        //显示错误信息
        that.showError('接口请求失败，请重试')
        return
      }
      // success
      var data = tool.getRegularJson(res.data);
      var code = data.code;
      console.log(res);
      if (code == 0) {
        that.setData({
          list: that.data.list.concat(data.data),
          listSearch: that.data.list.concat(data.data)

        });
        // that.setData({
        //  

        // });

      } else {
        that.setData({
          order_error: true
        });

      }
    },
    fail: function () {
      // fail
      that.setData({
        order_error: true
      });
    },
    complete: function () {
      // complete
      wx.hideToast();
      wx.stopPullDownRefresh();
    }
  })
}

//发布方法
function goPush(that) {
  if (that.data.title.length == 0) {
    that.showError('请输入标题')
    that.data.sendTag = 0;
    return;
  }

  if (that.data.title.length > 50) {
    that.showError('行程简介不能超过50个字')
    that.data.sendTag = 0;
    return;
  }

  if (that.data.dateStart.length == 0) {
    that.showError('请输入开始时间')
    that.data.sendTag = 0;
    return;
  }

  if (that.data.dateEnd.length == 0) {
    that.showError('请输入结束时间')
    that.data.sendTag = 0;
    return;
  }

  if (that.data.timeCheck1 == false) {
    that.data.dateStartTime = '00:00'
  }

  if (that.data.timeCheck2 == false) {
    that.data.dateEndTime = '23:59'
  }
  if (that.data.dateStartTime.length > 0) {
    that.setData({
      dateStartAll: that.data.dateStart + ' ' + that.data.dateStartTime
    })
  }


  if (that.data.dateEndTime.length > 0) {
    that.setData({
      dateEndAll: that.data.dateEnd + ' ' + that.data.dateEndTime
    })
  }
  // console.log(that.data.dateStart)
  // console.log(that.data.dateStartAll, that.data.dateEndAll)
  // return

  var d1 = new Date(that.data.dateStartAll);
  var d2 = new Date(that.data.dateEndAll);

  console.log(d1, d2)
  if (d1 > d2) {
    that.showError('开始日期大于结束日期，请重新输入')
    that.data.sendTag = 0;
    return
  }


  if (!that.isInteger(that.data.seatNum)) {
    that.showError('座位数应为整数')
    that.data.sendTag = 0;
    return
  }

  if (!that.isInteger(that.data.personNum)) {
    that.showError('人数应为整数')
    that.data.sendTag = 0;
    return
  }

  if (!that.isInteger(that.data.carNum)) {
    that.showError('车辆数应为整数')
    that.data.sendTag = 0;
    return
  }

  if (!that.isInteger(that.data.days)) {
    that.showError('天数应为整数')
    that.data.sendTag = 0;
    return
  }

  // if (that.data.seatNum < 5 || that.data.seatNum > 65) {
  //   if (that.data.seatNum.length == 0) {
  //     that.data.seatNum = -1
  // that.setData({
  //   seatNum: '-1'
  // })
  // }
  // else {
  //   that.showError('座位数为5~65')
  //   that.data.sendTag = 0;
  //   return
  // }

  // }

  // if (that.data.personNum < 1 || that.data.personNum > 65) {
  //   if (that.data.personNum.length == 0) {
  //     that.data.personNum = -1
  // that.setData({
  //   personNum: '-1'
  // })
  // }
  //  else {
  //   that.showError('人数为1~65')
  //   that.data.sendTag = 0;
  //   return
  // }
  // }

  // if (that.data.seatNum < that.data.personNum) 
  // if (that.data.personNum - that.data.seatNum > 0) {
  //   that.showError('人数大于座位数')
  //   that.data.sendTag = 0;
  //   return
  // }

  wx.showToast({
    title: '正在加载...',
    icon: 'loading',
    duration: 10000
  });
  var userInfo = wx.getStorageSync('userInfo');
  wx.request({
    url: 'https://www.lanshuicar.com/Server/agencyserver/NewOrderList.ashx',
    data: {
      UID: userInfo.ID,
      CarID: that.data.carCompanyIDmain,
      replyName: that.data.carCompanyperson2,
      replyTel: that.data.carCompanytel2,
      cgsName: that.data.carCompanyName2,
      SRequire: that.data.seatNum,
      peopleRequire: that.data.personNum,
      CarCount: that.data.carNum,
      HopePrice: that.data.price,
      InClued: that.data.BoolPrice,
      STime: that.data.dateStartAll,
      ETime: that.data.dateEndAll,
      DayNumber: that.data.days,
      GOnPlace: that.data.geton,
      GOffPlace: that.data.getoff,
      TrueStatus: that.data.OrderStatus,
      RouteTtle: that.data.title,
      RouteContent: that.data.route,
      Require: that.data.Addition
    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function (res) {
      if (res.statusCode == 404) {
        //接口加载失败
        console.log('加载接口错误');
        //隐藏Toast
        wx.hideToast();
        //显示错误信息
        that.showError('接口请求失败，请重试')
        return
      }
      if (res.statusCode == 500) {
        //接口加载失败
        console.log('加载接口错误');
        //显示错误信息
        that.showError('上下车地点不能超过25个字')
        //隐藏Toast
        wx.hideToast()
        return
      }

      // success
      var data = tool.getRegularJson(res.data);
      var code = data.code;
      console.log(res);
      if (code == 0) {
        var idd = data.data[0].idd
        console.log(idd)
        setTimeout(function () {
          wx.showToast({
            title: '发布成功',
          })
        }, 1500)

        that.PushToCarCompany(idd)

        that.data.sendTag = 0;
        wx.navigateBack();
        var pages = getCurrentPages()
        var backpage = pages[pages.length - 2]
        backpage.setData({
          backtag: 1,
        });


      } else {
        that.data.sendTag = 0;
        that.showError(res.data.msg)
        that.setData({
          order_error: true
        });


      }
    },
    fail: function () {
      // fail
      that.data.sendTag = 0;
      that.setData({
        order_error: true
      });
    },
    complete: function () {
      // complete
      that.data.sendTag = 0;
      wx.hideToast();
      wx.stopPullDownRefresh();
    }
  })
}

//修改方法
function xiugai(that) {





  if (that.data.title.length == 0) {
    that.showError('请输入标题')
    that.data.sendTag = 0;
    return;
  }





  if (that.data.dateStart.length == 0) {
    that.showError('请输入开始时间')
    that.data.sendTag = 0;
    return;
  }
  if (that.data.dateEnd.length == 0) {
    that.showError('请输入结束时间')
    that.data.sendTag = 0;
    return;
  }

  if (that.data.timeCheck1 == false) {
    that.data.dateStartTime = '00:00'
  }

  if (that.data.timeCheck2 == false) {
    that.data.dateEndTime = '23:59'
  }

  if (that.data.dateStartTime.length > 0) {
    that.setData({
      dateStartAll: that.data.dateStart + ' ' + that.data.dateStartTime
    })
  }
  if (that.data.dateEndTime.length > 0) {
    that.setData({
      dateEndAll: that.data.dateEnd + ' ' + that.data.dateEndTime
    })
  }
  var d1 = new Date(that.data.dateStartAll);
  var d2 = new Date(that.data.dateEndAll);

  console.log(d1, d2)
  if (d1 > d2) {
    that.showError('开始日期大于结束日期，请重新输入')
    that.data.sendTag = 0;
    return
  }


  // if (that.data.seatNum < 5 || that.data.seatNum > 65) {
  //   if (that.data.seatNum.length == 0) {
  //     that.data.seatNum = -1
  // that.setData({
  //   seatNum: '-1'
  // })
  // }
  // else {
  //   that.showError('座位数为5~65')
  //   that.data.sendTag = 0;
  //   return
  // }

  // }

  // if (that.data.personNum < 1 || that.data.personNum > 65) {
  //   if (that.data.personNum.length == 0) {
  //     that.data.personNum = -1
  // that.setData({
  //   personNum: '-1'
  // })
  // }
  // else {
  //   that.showError('人数为1~65')
  //   that.data.sendTag = 0;
  //   return
  // }

  // }

  // if (that.data.seatNum < that.data.personNum) {
  //   that.showError('人数大于座位数')
  //   that.data.sendTag = 0;
  //   return
  // }





  //将修改完数据放入一个数组，
  var arrcompare = []
  arrcompare = arrcompare.concat(that.data.title)
  arrcompare = arrcompare.concat(that.data.carCompanyNamemain)
  arrcompare = arrcompare.concat(that.data.geton)
  arrcompare = arrcompare.concat(that.data.getoff)
  arrcompare = arrcompare.concat(that.data.seatNum)
  arrcompare = arrcompare.concat(that.data.personNum)
  arrcompare = arrcompare.concat(that.data.carNum)
  arrcompare = arrcompare.concat(that.data.days)
  arrcompare = arrcompare.concat(that.data.dateStart)
  arrcompare = arrcompare.concat(that.data.dateStartTime)
  arrcompare = arrcompare.concat(that.data.dateEnd)
  arrcompare = arrcompare.concat(that.data.dateEndTime)
  arrcompare = arrcompare.concat(that.data.price)
  arrcompare = arrcompare.concat(that.data.OrderStatus)
  arrcompare = arrcompare.concat(that.data.route)
  arrcompare = arrcompare.concat(that.data.Addition)
  arrcompare = arrcompare.concat(that.data.carCompanyIDmain)
  arrcompare = arrcompare.concat(that.data.BoolPrice)
  that.data.arrlatest.push(arrcompare)
  console.log(that.data.arrlatest)

  //修改完的用车时间和行程
  var dataAndroutelatest = []
  var dataAndroute2 = []
  dataAndroute2 = dataAndroute2.concat(that.data.dateStart)
  dataAndroute2 = dataAndroute2.concat(that.data.dateStartTime)
  dataAndroute2 = dataAndroute2.concat(that.data.dateEnd)
  dataAndroute2 = dataAndroute2.concat(that.data.dateEndTime)
  dataAndroute2 = dataAndroute2.concat(that.data.route)
  dataAndroutelatest.push(dataAndroute2)

  if (that.data.carCompanyIDmain == -1 || that.data.carCompanyIDmain == 0) {
    that.data.carCompanyIDmain = ''
  }

  //用json转成字符串
  var jarray1 = JSON.stringify(that.data.arrcompare2)
  var jarray2 = JSON.stringify(that.data.arrlatest)
  //未修改什么都不做
  if (jarray1 == jarray2) {
    console.log('未修改内容')
    that.data.sendTag = 0;
    wx.navigateBack();
    return
  }
  //修改过了就判断是改了什么再进行相关角色的推送
  else {
    console.log('修改了内容')
    //只要改动了就通知车公司
    //***************************
    that.PushToCarCompanyChange(that.data.IDD)
    //调用方法
    //***************************

    //如果用车日期和行程变更了 还要推送给其他几个角色,乘客，导游和司机
    console.log(that.data.dateAndroute1)
    console.log(dataAndroutelatest)
    var dateAndroutestr1 = JSON.stringify(that.data.dateAndroute1)
    var dateAndroutestr2 = JSON.stringify(dataAndroutelatest)
    if (dateAndroutestr1 == dateAndroutestr2) {
      console.log('没有变更时期和行程，不推送给其他几个角色')
    } else {
      console.log('日期和行程变更了,推送给其他几个角色')
      //***************************
      //调用方法
      getDataGuider(that)
      getDataDriver(that)
      getDataChengke(that)

      //***************************
    }


  }


  wx.showToast({
    title: '正在加载...',
    icon: 'loading',
    duration: 10000
  });
  var userInfo = wx.getStorageSync('userInfo');
  // console.log('###')
  // console.log(that.data.carCompanyIDmain)
  wx.request({
    url: 'https://www.lanshuicar.com/Server/AgencyServer/UpdateOrder.ashx',
    data: {
      IDD: that.data.IDD,
      CarID: that.data.carCompanyIDmain,
      replyName: that.data.carCompanyperson2,
      replyTel: that.data.carCompanytel2,
      cgsName: that.data.carCompanyName2,
      SRequire: that.data.seatNum,
      peopleRequire: that.data.personNum,
      CarCount: that.data.carNum,
      HopePrice: that.data.price,
      InClued: that.data.BoolPrice,
      STime: that.data.dateStartAll,
      ETime: that.data.dateEndAll,
      DayNumber: that.data.days,
      GOnPlace: that.data.geton,
      GOffPlace: that.data.getoff,
      TrueStatus: that.data.OrderStatus,
      RouteTtle: that.data.title,
      RouteContent: that.data.route,
      Require: that.data.Addition
    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function (res) {
      if (res.statusCode == 404) {
        //接口加载失败
        console.log('加载接口错误');
        //隐藏Toast
        wx.hideToast();
        //显示错误信息
        that.showError('接口请求失败，请重试')
        return
      }

      if (res.statusCode == 500) {
        //接口加载失败
        console.log('加载接口错误');
        //显示错误信息
        that.showError('上下车地点不能超过25个字')
        //隐藏Toast
        wx.hideToast()
        return
      }
      // success
      var data = tool.getRegularJson(res.data);
      var code = data.code;
      console.log(res);
      if (code == 0) {
        wx.showToast({
          title: '修改成功',
        })
        that.data.sendTag = 0;
        wx.navigateBack();
        var pages = getCurrentPages()
        var backpage = pages[pages.length - 3]
        backpage.setData({
          backtag: 1,
        });
      } else {
        that.showError(res.data.msg)
      }
    },
    fail: function () {
      that.data.sendTag = 0;
    },
    complete: function () {
      that.data.sendTag = 0;
      wx.hideToast();
      wx.stopPullDownRefresh();
    }
  })
}


function getServiceDataChange(that) {
  var thatt = that
  wx.showToast({
    title: '正在加载...',
    icon: 'loading',
    duration: 10000
  });

  var userInfo = wx.getStorageSync('userInfo');
  wx.request({
    url: 'https://www.lanshuicar.com/Server/AgencyServer/OrderInfo.ashx',
    data: {
      IDD: thatt.data.IDD,
      methd: '0'
    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function (res) {
      if (res.statusCode == 404) {
        //接口加载失败
        console.log('加载接口错误');
        //隐藏Toast
        wx.hideToast();
        //显示错误信息
        that.showError('接口请求失败，请重试')
        return
      }
      // success

      var data = tool.getRegularJson(res.data);
      var code = data.code;
      var arr = [];
      console.log(res);
      if (code == 0) {
        thatt.data.listchange = data.data[0]

        arr = data.data[0]
        thatt.setData({
          DriverName: arr.DriverName
        })
        thatt.setData({
          title: arr.routeTitle,
          carCompanyNamemain: arr.CarCompanyName,
          carCompanypersonmain: arr.replyContrant,
          geton: arr.GetOnPlace,
          getoff: arr.GetOffPlace,
          seatNum: arr.seatRequire,
          personNum: arr.peopleRequire,
          carNum: arr.carcount,
          days: arr.DayNumber,
          dateStart: arr.UseCarStartTime.substring(0, 10),
          dateStartTime: arr.UseCarStartTime.substring(11, 16),
          dateEnd: arr.UseCarEndTime.substring(0, 10),
          dateEndTime: arr.UseCarEndTime.substring(11, 16),
          price: arr.HopePrice,
          OrderStatus: arr.AgenycyStatus,
          route: arr.Route,
          Addition: arr.OtherRequire,
          carCompanyIDmain: arr.CarCompanyID,
          BoolPrice: arr.inclued,
          carCompanypersontel: arr.replyTel


        });
        // console.log(thatt.data.carCompanyIDmain)

        if (that.data.dateStartTime == '00:00' && that.data.dateEndTime == '23:59') {
          that.setData({
            timeCheck1: false,
            timeCheck2: false
          })
        } else {
          that.setData({
            timeCheck1: true,
            timeCheck2: true,
          })
        }

        if (thatt.data.personNum == 0) {
          thatt.setData({
            personNum: ''
          })
        }
        if (thatt.data.seatNum == 0) {
          thatt.setData({
            seatNum: ''
          })
        }
        if (thatt.data.carNum == 0) {
          thatt.setData({
            carNum: ''
          })
        }

        console.log(thatt.data.BoolPrice)
        console.log(thatt.data.OrderStatus)
        if (thatt.data.BoolPrice == 1) {
          thatt.setData({
            arrayPrice: [
              { name: "是", value: '1', checked: true },
              { name: '否', value: '0', checked: false }
            ],
          })
        } else {
          thatt.setData({
            arrayPrice: [
              { name: "是", value: '1', checked: false },
              { name: '否', value: '0', checked: true }
            ],
          })
        }

        if (thatt.data.OrderStatus == 1) {
          thatt.setData({
            arrayStatus: [
              { name: "已确认", value: "1", checked: true },
              { name: "未确认", value: "0", checked: false },
              { name: "取消", value: "2", checked: false }
            ],
          })
        } else if (thatt.data.OrderStatus == 0) {
          thatt.setData({
            arrayStatus: [
              { name: "已确认", value: "1", checked: false },
              { name: "未确认", value: "0", checked: true },
              { name: "取消", value: "2", checked: false }
            ],
          })
        } else if (thatt.data.OrderStatus == 2) {
          thatt.setData({
            arrayStatus: [
              { name: "已确认", value: "1", checked: false },
              { name: "未确认", value: "0", checked: false },
              { name: "取消", value: "2", checked: true }
            ],
          })
        }




        //将数据放入一个数组，在保存的时候判断是否有过订单变动
        var arrcompare = []
        arrcompare = arrcompare.concat(thatt.data.title)
        arrcompare = arrcompare.concat(thatt.data.carCompanyNamemain)
        arrcompare = arrcompare.concat(thatt.data.geton)
        arrcompare = arrcompare.concat(thatt.data.getoff)
        arrcompare = arrcompare.concat(thatt.data.seatNum)
        arrcompare = arrcompare.concat(thatt.data.personNum)
        arrcompare = arrcompare.concat(thatt.data.carNum)
        arrcompare = arrcompare.concat(thatt.data.days)
        arrcompare = arrcompare.concat(thatt.data.dateStart)
        arrcompare = arrcompare.concat(thatt.data.dateStartTime)
        arrcompare = arrcompare.concat(thatt.data.dateEnd)
        arrcompare = arrcompare.concat(thatt.data.dateEndTime)
        arrcompare = arrcompare.concat(thatt.data.price)
        arrcompare = arrcompare.concat(thatt.data.OrderStatus)
        arrcompare = arrcompare.concat(thatt.data.route)
        arrcompare = arrcompare.concat(thatt.data.Addition)
        arrcompare = arrcompare.concat(thatt.data.carCompanyIDmain)
        arrcompare = arrcompare.concat(thatt.data.BoolPrice)
        thatt.data.arrcompare2.push(arrcompare)
        console.log(thatt.data.arrcompare2)

        //初始的用车时间和行程
        var dateAndroute = []
        dateAndroute = dateAndroute.concat(thatt.data.dateStart)
        dateAndroute = dateAndroute.concat(thatt.data.dateStartTime)
        dateAndroute = dateAndroute.concat(thatt.data.dateEnd)
        dateAndroute = dateAndroute.concat(thatt.data.dateEndTime)
        dateAndroute = dateAndroute.concat(thatt.data.route)
        thatt.data.dateAndroute1.push(dateAndroute)


        //加载数据
      } else {
        thatt.setData({
          order_error: true
        });

      }
    },
    fail: function () {
      // fail
      thatt.setData({
        order_error: true
      });
    },
    complete: function () {
      // complete
      wx.hideToast();
      wx.stopPullDownRefresh();
    }
  })
}

//添加合作公司搜索方法
function getDataAddCar(that) {
  if (that.data.AddKeyWord.length <= 0) {
    that.showError('请输入搜索内容')
    return
  }
  //初始化list
  that.data.listAdd = []
  wx.showToast({
    title: '正在加载...',
    icon: 'loading',
    duration: 10000
  });
  var userInfo = wx.getStorageSync('userInfo');
  wx.request({
    url: 'https://www.lanshuicar.com/Server/CooPeratePartners.ashx',
    data: {
      PageSize: '200',
      PageIndex: '1',
      Type: '1',
      ID: userInfo.ID,
      CType: '1',
      Info: '1',
      Conditions: that.data.AddKeyWord
    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function (res) {
      if (res.statusCode == 404) {
        //接口加载失败
        console.log('加载接口错误');
        //隐藏Toast
        wx.hideToast();
        //显示错误信息
        that.showError('接口请求失败，请重试')
        return
      }
      // success
      var data = tool.getRegularJson(res.data);
      var code = data.code;
      console.log(res);
      if (code == 0) {
        that.setData({
          listAdd: that.data.listAdd.concat(data.data),
        });
        console.log(that.data.listAdd)
        if (that.data.listAdd.length == 0) {
          console.log('搜索提示')
          wx.showToast({
            title: '没有搜索的车公司',
            icon: 'none',
            duration: 1000,
          })
        }
        // that.setData({
        //  

        // });

      } else {


      }
    },
    fail: function () {

    },
    complete: function () {
      wx.hideToast();
      wx.stopPullDownRefresh();
    }
  })
}

//拉进团队方法
function pulltoTeam(that) {
  wx.showToast({
    title: '正在加载...',
    icon: 'loading',
    duration: 10000
  });
  var userInfo = wx.getStorageSync('userInfo');
  wx.request({
    url: 'https://www.lanshuicar.com/Server/AgencyServer/AgencyAddCoopPartners.ashx',
    data: {
      ID: userInfo.ID,
      PID: that.data.carCompanyIDAdd,
      Type: '3',
      OpType: '0'
    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function (res) {
      if (res.statusCode == 404) {
        //接口加载失败
        console.log('加载接口错误');
        //隐藏Toast
        wx.hideToast();
        //显示错误信息
        that.showError('接口请求失败，请重试')
        return
      }
      // success
      var data = tool.getRegularJson(res.data);
      var code = data.code;
      console.log(res);
      if (code == 0) {
        wx.showToast({
          title: '拉入团队成功',
        })



      } else {


      }
    },
    fail: function () {

    },
    complete: function () {
      wx.hideToast();
      wx.stopPullDownRefresh();
    }
  })
}

//移出合作团队方法
function remove(that) {
  wx.showToast({
    title: '正在加载...',
    icon: 'loading',
    duration: 10000
  });
  var userInfo = wx.getStorageSync('userInfo');
  wx.request({
    url: 'https://www.lanshuicar.com/Server/AgencyServer/AgencyAddCoopPartners.ashx',
    data: {
      ID: userInfo.ID,
      PID: that.data.carCompanyIDDelete,
      Type: '3',
      OpType: '1'
    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function (res) {
      if (res.statusCode == 404) {
        //接口加载失败
        console.log('加载接口错误');
        //隐藏Toast
        wx.hideToast();
        //显示错误信息
        that.showError('接口请求失败，请重试')
        return
      }
      // success
      var data = tool.getRegularJson(res.data);
      var code = data.code;
      console.log(res);
      if (code == 0) {
        wx.showToast({
          title: '移出团队成功',
        })

        for (var i = 0; i < that.data.listDelete.length; i++) {
          var array = that.data.listDelete[i];
          if (array.CompanyID == that.data.carCompanyIDDelete) {
            that.data.listDelete.splice(i, 1);
          }
        }
        for (var i = 0; i < that.data.listDeleteSearch.length; i++) {
          var array = that.data.listDeleteSearch[i];
          if (array.CompanyID == that.data.carCompanyIDDelete) {
            that.data.listDeleteSearch.splice(i, 1);
          }
        }
        that.setData({
          listDelete: that.data.listDelete,
          listDeleteSearch: that.data.listDeleteSearch
        });
      } else {


      }
    },
    fail: function () {

    },
    complete: function () {
      wx.hideToast();
      wx.stopPullDownRefresh();
    }
  })
}

function DateDiff(d1, d2) {
  var day = 24 * 60 * 60 * 1000;
  var dateArr = d1.split("-");
  var checkDate = new Date();
  checkDate.setFullYear(dateArr[0], dateArr[1] - 1, dateArr[2]);
  var checkTime = checkDate.getTime();

  var dateArr2 = d2.split("-");
  var checkDate2 = new Date();
  checkDate2.setFullYear(dateArr2[0], dateArr2[1] - 1, dateArr2[2]);
  var checkTime2 = checkDate2.getTime();

  var cha = (checkTime - checkTime2) / day;
  return cha;
}//end fun

function DateDiff2(d1, d2) {
  var day = 24 * 60 * 60 * 1000;
  var dateArr = d1.split("-");
  var checkDate = new Date();
  checkDate.setFullYear(dateArr[0], dateArr[1] - 1, dateArr[2]);
  var checkTime = checkDate.getTime();

  var dateArr2 = d2.split("-");
  var checkDate2 = new Date();
  checkDate2.setFullYear(dateArr2[0], dateArr2[1] - 1, dateArr2[2]);
  var checkTime2 = checkDate2.getTime();

  var cha = (checkTime - checkTime2) / day;
  return cha;
}//end fun

//比较订单是否变动了
function compareOrder() {

}


function getDataGuider(that) {
  var listGuider = []
  wx.showToast({
    title: '正在加载...',
    icon: 'loading',
    duration: 10000
  });
  var userInfo = wx.getStorageSync('userInfo');
  console.log(userInfo);
  wx.request({
    url: 'https://www.lanshuicar.com/Server/GetCarsGuidersCusts.ashx',
    data: {
      Tel: userInfo.Telphone,
      IDD: that.data.IDD,
      OType: '2',
      PageIndex: '1',
      PageSize: '200',
      UType: '2',
      UID: userInfo.ID
    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function (res) {
      if (res.statusCode == 404) {
        //接口加载失败
        console.log('加载接口错误');
        //隐藏Toast
        wx.hideToast();
        //显示错误信息
        that.showError('接口请求失败，请重试')
        return
      }
      // success

      var data = tool.getRegularJson(res.data);
      var code = data.code;
      console.log(res);
      if (code == 0) {
        listGuider = listGuider.concat(data.data)
        for (var i = 0; i < listGuider.length; i++) {
          that.PushToGuiderDriverChengke(listGuider[i].GuiderTelphone)
          console.log('post导游')
        }

      } else {

      }
    },
    fail: function () {
      // fail
      that.setData({
        order_error: true
      });
    },
    complete: function () {
      // complete
      wx.hideToast();
      wx.stopPullDownRefresh();
    }
  })
}

function getDataDriver(that) {
  var listDriver = []
  wx.showToast({
    title: '正在加载...',
    icon: 'loading',
    duration: 10000
  });
  var userInfo = wx.getStorageSync('userInfo');
  var username = wx.getStorageSync('username');
  var userpwd = wx.getStorageSync('password');
  console.log(userInfo);
  wx.request({
    url: 'https://www.lanshuicar.com/Server/DriverPerson/GetDriverCarInfo.ashx',
    data: {
      idd: that.data.IDD,
      tel: username,
      pwd: userpwd
    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function (res) {
      if (res.statusCode == 404) {
        //接口加载失败
        console.log('加载接口错误');
        //隐藏Toast
        wx.hideToast();
        //显示错误信息
        that.showError('接口请求失败，请重试')
        return
      }
      // success

      var data = tool.getRegularJson(res.data);
      var code = data.code;
      console.log(res);
      if (code == 0) {
        listDriver = listDriver.concat(data.data)
        for (var i = 0; i < listDriver.length; i++) {
          that.PushToGuiderDriverChengke(listDriver[i].sTel)
          console.log('post司机')
        }

      } else {

      }
    },
    fail: function () {
      // fail
      that.setData({
        order_error: true
      });
    },
    complete: function () {
      // complete
      wx.hideToast();
      wx.stopPullDownRefresh();
    }
  })
}

function getDataChengke(that) {
  var listChengke = []
  wx.showToast({
    title: '正在加载...',
    icon: 'loading',
    duration: 10000
  });
  var userInfo = wx.getStorageSync('userInfo');
  console.log(userInfo);
  wx.request({
    url: 'https://www.lanshuicar.com/Server/GetCarsGuidersCusts.ashx',
    data: {
      OType: '1',
      IDD: that.data.IDD,
      PageSize: '200',
      UID: userInfo.ID,
      UType: '2',
      PageIndex: '1'
    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function (res) {
      if (res.statusCode == 404) {
        //接口加载失败
        console.log('加载接口错误');
        //隐藏Toast
        wx.hideToast();
        //显示错误信息
        that.showError('接口请求失败，请重试')
        return
      }
      // success

      var data = tool.getRegularJson(res.data);
      var code = data.code;
      console.log(res);
      if (code == 0) {
        listChengke = listChengke.concat(data.data)
        for (var i = 0; i < listChengke.length; i++) {
          that.PushToGuiderDriverChengke(listChengke[i].cCustomerTel)
          console.log('post乘客')
        }

      } else {

      }
    },
    fail: function () {
      // fail
      that.setData({
        order_error: true
      });
    },
    complete: function () {
      // complete
      wx.hideToast();
      wx.stopPullDownRefresh();
    }
  })
}